﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    public class ThongTinCongTy
    {
        private string mDiaChiAnh = "";
        private string mDiaChiNganHang = "";
        private string mDiaChiViet = "";
        private string mDienThoai = "";
        private string mEmail = "";
        private string mFax = "";
        private byte[] mFooter;
        private byte[] mHeader;
        private string mHotLine = "";
        private string mKhoaDonVi = "";
        private byte[] mLogo;
        private string mMaSoThue = "";
        private string mPhienBanQuyetDinh = "";
        private string mSoTaiKhoanUSD = "";
        private string mSoTaiKhoanVND = "";
        private string mSwiftCode = "";
        private string mTenCongTyAnh = "";
        private string mTenCongTyViet = "";
        private string mTenNganHang = "";
        private string mTenTaiKhoan = "";
        private string mWebsite = "";

        public bool ChuyenDiaDiem(string strNgayChuyen, string strDiaChiMoi)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[3];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@NgayChuyen", DbType.Int64, ParameterDirection.Input, strNgayChuyen);
                commandParameters[1] = DBHelper.createParameter("@DiaChiMoi", DbType.Int64, ParameterDirection.Input, strDiaChiMoi);
                commandParameters[2] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, modGeneral.H_CLIENT);
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_ChuyenDiaDiem", commandParameters) > 0;
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetList()
        {
            IDataParameter parameter = null;
            DataTable table;
            try
            {
                string commandText = "SELECT NgayChuyen, DiaChiViet FROM HT_Company ORDER BY NgayChuyen DESC";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool Load(string strKhoaDonVi)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM HT_Company WHERE Active = 1 and KhoaDonVi = '" + strKhoaDonVi + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mTenCongTyViet = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mTenCongTyAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiViet = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mTenNganHang = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mTenTaiKhoan = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mSoTaiKhoanUSD = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mSoTaiKhoanVND = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiNganHang = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mSwiftCode = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mDienThoai = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mFax = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mEmail = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mWebsite = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mHotLine = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mPhienBanQuyetDinh = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                commandText = " SELECT Logo FROM HT_Company WHERE Active = 1 and KhoaDonVi = '" + strKhoaDonVi + "'";
                this.mLogo = (byte[]) LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0])), null, modGeneral.TypeOfValue.Nothing);
                commandText = " SELECT Header FROM HT_Company WHERE Active = 1 and KhoaDonVi = '" + strKhoaDonVi + "'";
                this.mHeader = (byte[]) LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0])), null, modGeneral.TypeOfValue.Nothing);
                commandText = " SELECT Footer FROM HT_Company WHERE Active = 1 and KhoaDonVi = '" + strKhoaDonVi + "'";
                this.mFooter = (byte[]) LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0])), null, modGeneral.TypeOfValue.Nothing);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x12];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@TenCongTyViet", DbType.Int64, ParameterDirection.Input, this.mTenCongTyViet);
                commandParameters[1] = DBHelper.createParameter("@TenCongTyAnh", DbType.Int64, ParameterDirection.Input, this.mTenCongTyAnh);
                commandParameters[2] = DBHelper.createParameter("@DiaChiViet", DbType.Int64, ParameterDirection.Input, this.mDiaChiViet);
                commandParameters[3] = DBHelper.createParameter("@DiaChiAnh", DbType.Int64, ParameterDirection.Input, this.mDiaChiAnh);
                commandParameters[4] = DBHelper.createParameter("@TenNganHang", DbType.Int64, ParameterDirection.Input, this.mTenNganHang);
                commandParameters[5] = DBHelper.createParameter("@TenTaiKhoan", DbType.Int64, ParameterDirection.Input, this.mTenTaiKhoan);
                commandParameters[6] = DBHelper.createParameter("@SoTaiKhoanUSD", DbType.Int64, ParameterDirection.Input, this.mSoTaiKhoanUSD);
                commandParameters[7] = DBHelper.createParameter("@SoTaiKhoanVND", DbType.Int64, ParameterDirection.Input, this.mSoTaiKhoanVND);
                commandParameters[8] = DBHelper.createParameter("@DiaChiNganHang", DbType.Int64, ParameterDirection.Input, this.mDiaChiNganHang);
                commandParameters[9] = DBHelper.createParameter("@SwiftCode", DbType.Int64, ParameterDirection.Input, this.mSwiftCode);
                commandParameters[10] = DBHelper.createParameter("@DienThoai", DbType.Int64, ParameterDirection.Input, this.mDienThoai);
                commandParameters[11] = DBHelper.createParameter("@Fax", DbType.Int64, ParameterDirection.Input, this.mFax);
                commandParameters[12] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[13] = DBHelper.createParameter("@Email", DbType.Int64, ParameterDirection.Input, this.mEmail);
                commandParameters[14] = DBHelper.createParameter("@Website", DbType.Int64, ParameterDirection.Input, this.mWebsite);
                commandParameters[15] = DBHelper.createParameter("@HotLine", DbType.Int64, ParameterDirection.Input, this.mHotLine);
                commandParameters[0x10] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x11] = DBHelper.createParameter("@PhienBanQuyetDinh", DbType.Int64, ParameterDirection.Input, this.mPhienBanQuyetDinh);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_ThongTinCongTy", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool UpdateLogo(int intLoai)
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                switch (intLoai)
                {
                    case 0:
                        commandParameters[0] = DBHelper.createParameter("@Img", DbType.Decimal, ParameterDirection.Input, this.mLogo);
                        break;

                    case 1:
                        commandParameters[0] = DBHelper.createParameter("@Img", DbType.Decimal, ParameterDirection.Input, this.mHeader);
                        break;

                    case 2:
                        commandParameters[0] = DBHelper.createParameter("@Img", DbType.Decimal, ParameterDirection.Input, this.mFooter);
                        break;
                }
                commandParameters[1] = DBHelper.createParameter("@Loai", DbType.Double, ParameterDirection.Input, intLoai);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "HT_UpdateLogo", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public string DiaChiAnh
        {
            get
            {
                return this.mDiaChiAnh;
            }
            set
            {
                this.mDiaChiAnh = value;
            }
        }

        public string DiaChiNganHang
        {
            get
            {
                return this.mDiaChiNganHang;
            }
            set
            {
                this.mDiaChiNganHang = value;
            }
        }

        public string DiaChiViet
        {
            get
            {
                return this.mDiaChiViet;
            }
            set
            {
                this.mDiaChiViet = value;
            }
        }

        public string DienThoai
        {
            get
            {
                return this.mDienThoai;
            }
            set
            {
                this.mDienThoai = value;
            }
        }

        public string Email
        {
            get
            {
                return this.mEmail;
            }
            set
            {
                this.mEmail = value;
            }
        }

        public string Fax
        {
            get
            {
                return this.mFax;
            }
            set
            {
                this.mFax = value;
            }
        }

        public byte[] Footer
        {
            get
            {
                return this.mFooter;
            }
            set
            {
                this.mFooter = value;
            }
        }

        public byte[] Header
        {
            get
            {
                return this.mHeader;
            }
            set
            {
                this.mHeader = value;
            }
        }

        public string HotLine
        {
            get
            {
                return this.mHotLine;
            }
            set
            {
                this.mHotLine = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public byte[] Logo
        {
            get
            {
                return this.mLogo;
            }
            set
            {
                this.mLogo = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string PhienBanQuyetDinh
        {
            get
            {
                return this.mPhienBanQuyetDinh;
            }
            set
            {
                this.mPhienBanQuyetDinh = value;
            }
        }

        public string SoTaiKhoanUSD
        {
            get
            {
                return this.mSoTaiKhoanUSD;
            }
            set
            {
                this.mSoTaiKhoanUSD = value;
            }
        }

        public string SoTaiKhoanVND
        {
            get
            {
                return this.mSoTaiKhoanVND;
            }
            set
            {
                this.mSoTaiKhoanVND = value;
            }
        }

        public string SwiftCode
        {
            get
            {
                return this.mSwiftCode;
            }
            set
            {
                this.mSwiftCode = value;
            }
        }

        public string TenCongTyAnh
        {
            get
            {
                return this.mTenCongTyAnh;
            }
            set
            {
                this.mTenCongTyAnh = value;
            }
        }

        public string TenCongTyViet
        {
            get
            {
                return this.mTenCongTyViet;
            }
            set
            {
                this.mTenCongTyViet = value;
            }
        }

        public string TenNganHang
        {
            get
            {
                return this.mTenNganHang;
            }
            set
            {
                this.mTenNganHang = value;
            }
        }

        public string TenTaiKhoan
        {
            get
            {
                return this.mTenTaiKhoan;
            }
            set
            {
                this.mTenTaiKhoan = value;
            }
        }

        public string Website
        {
            get
            {
                return this.mWebsite;
            }
            set
            {
                this.mWebsite = value;
            }
        }
    }
}

